import request from '@/utils/request'

// 查询人员信息列表
export function listTenant(query) {
  return request({
    url: '/tenantuser/tenant/list',
    method: 'get',
    params: query
  })
}
export function listTenantRuzhu(query) {
  return request({
    url: '/tenantuser/tenant/listruzhu',
    method: 'get',
    params: query
  })
}
// 查询人员信息列表
export function listTenant3(query) {
  return request({
    url: '/tenantuser/tenant/list3',
    method: 'get',
    params: query
  })
}
// 查询人员信息详细
export function getTenant(id) {
  return request({
    url: '/tenantuser/tenant/' + id,
    method: 'get'
  })
}

// 新增人员信息
export function addTenant(data) {
  return request({
    url: '/tenantuser/tenant',
    method: 'post',
    data: data
  })
}

// 修改人员信息
export function updateTenant(data) {
  return request({
    url: '/tenantuser/tenant',
    method: 'put',
    data: data
  })
}

// 删除人员信息
export function delTenant(id) {
  return request({
    url: '/tenantuser/tenant/' + id,
    method: 'delete'
  })
}

// 人员授权钥匙
export function tenantToKey(data) {
  return request({
    url: '/tenantuser/tenant/toKey',
    method: 'post',
    data: data
  })
}

// 获取没有卡片钥匙的房间
export function getRoomsWithoutCardKey(id) {
  return request({
    url: '/tenantuser/tenant/roomsWithoutCardKey/' + id,
    method: 'get'
  })
}

// 更新人员状态（包含钥匙删除逻辑）
export function updateTenantStatus(data) {
  return request({
    url: '/tenantuser/tenant/updateStatus',
    method: 'put',
    data: data
  })
}
// 获取入住二维码
export function getQrCode(homeId) {
  return request({
    url: '/tenantuser/tenant/qrcode/' + homeId,
    method: 'get'
  })
}

// 查询未入住用户
export function listTenantNotRuzhu(query) {
  return request({
    url: '/tenantuser/tenant/listNotRuZhu',
    method: 'get',
    params: query
  })
}

// 批量插入入住中间表
export function addHomeUser(data) {
  return request({
    url: '/lock/homeUser/batchAdd',
    method: 'post',
    data
  })
}

// 批量入住接口 - 一个人入住多个房间
export function batchRuzhu(data) {
  return request({
    url: '/lock/homeUser/batchRuzhu',
    method: 'post',
    data
  })
}

// 根据用户ID和房间ID查询入住用户信息
export function getTenantRuzhuInfo(query) {
  return request({
    url: '/tenantuser/tenant/ruzhuinfo/userId',
    method: 'get',
    params: query
  })
}

// 根据用户ID和房间ID查询入住用户信息（路径参数方式）
export function getTenantRuzhuInfoByPath(id, homeId) {
  return request({
    url: `/tenantuser/tenant/ruzhuinfo/${id}/${homeId}`,
    method: 'get'
  })
}

// 退房接口
export function apartmentRoomSingleCheckOut(data) {
  return request({
    url: '/cat1lock/apartmentRoomSingleCheckOut',
    method: 'post',
    data: data
  })
}

// 根据用户ID退房接口
export function apartmentRoomCheckOut(data) {
  return request({
    url: '/cat1lock/apartmentRoomCheckOut',
    method: 'post',
    data: data
  })
}

// 房间退租接口
export function roomCheckOut(data) {
  return request({
    url: '/cat1lock/roomCheckOut',
    method: 'post',
    data: data
  })
}

// Oracle数据同步 - 全量同步
export function syncOracleAll() {
  return request({
    url: '/tenantuser/tenant/syncOracle/all',
    method: 'post'
  })
}

// Oracle数据同步 - 增量同步
export function syncOracleCurrent() {
  return request({
    url: '/tenantuser/tenant/syncOracle/current',
    method: 'post'
  })
}

// Oracle数据同步 - 测试同步
export function syncOracleTest() {
  return request({
    url: '/tenantuser/tenant/syncOracle/test',
    method: 'post'
  })
}
